package com.dj.controller;

import com.dj.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Author DJ同学
 * @Date 2021/2/26 19:22
 * @Version 1.0
 */
@Controller
public class ContentController {
    @Autowired
    private ContentService contentService;

//    @ResponseBody
    @GetMapping("/getData/{keyword}")
    public Boolean getData (@PathVariable  String keyword) throws IOException {
        return   contentService.parseContent(keyword);
    }

    @ResponseBody
    @GetMapping("/search/{keyword}/{pageIndex}/{pageSize}")
    public List<Map<String, Object>> parse(@PathVariable("keyword") String keyword,
                                           @PathVariable("pageIndex") Integer pageIndex,
                                           @PathVariable("pageSize") Integer pageSize) throws IOException {
        return contentService.search(keyword,pageIndex,pageSize);
    }
}
